package top.chenfu.blog.scheduled;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import top.chenfu.blog.service.PvService;

import java.text.DateFormat;
import java.util.Date;

/**
 * @Auther chenfu
 * @2019/11/1 11:42
 * @Desc
 */
@Component
@Slf4j
public class DataStatisticsScheduled {

    @Autowired
    private PvService pvService;

    //    每天跑一次
    @Scheduled(cron = "1 0 0 * * ?")
//    测试一分钟跑一次
//    @Scheduled(cron = "1 * * * * ?")
    public void pvStatisticsPerDay() {
        log.info("定时统计任务开始运行{}", DateFormat.getDateTimeInstance().format(new Date()));
        pvService.pvStatisticsPerDay();
    }

}
